﻿using System;
using System.Linq;

namespace SystemX.Services
{
    /// <summary>
    /// Represents a data access repository.
    /// </summary>
    /// <typeparam name="T">Dto type or Dto interface type</typeparam>
    /// <typeparam name="TId">Id type of the domain object.</typeparam>
    public interface IRepository<T,TId>
    {
        /// <summary>
        /// Create an <see cref="IContext"/> instance for the repository.Provides transactional process.
        /// </summary>
        IContext NewTrans();
        /// <summary>
        /// get all records
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetAll();
        /// <summary>
        /// Find a record by primary key
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        T Find(TId Id);
        /// <summary>
        /// Save a record.Maybe add new or update.
        /// </summary>
        void Save(T obj);
        /// <summary>
        /// Delete a record
        /// </summary>
        void Delete(TId objKey);
    }
}
